/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entidades;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author lomanda
 */
@Entity
@Table(name = "encomenda")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Encomenda.findAll", query = "SELECT e FROM Encomenda e"),
    @NamedQuery(name = "Encomenda.findByIdEncomenda", query = "SELECT e FROM Encomenda e WHERE e.idEncomenda = :idEncomenda"),
    @NamedQuery(name = "Encomenda.findByData", query = "SELECT e FROM Encomenda e WHERE e.data = :data"),
    @NamedQuery(name = "Encomenda.findByHora", query = "SELECT e FROM Encomenda e WHERE e.hora = :hora"),
    @NamedQuery(name = "Encomenda.findByRecebeu", query = "SELECT e FROM Encomenda e WHERE e.recebeu = :recebeu"),
    @NamedQuery(name = "Encomenda.findByEstado", query = "SELECT e FROM Encomenda e WHERE e.estado = :estado")})
public class Encomenda implements Serializable {
    @Basic(optional = false)
    @NotNull
    @Column(name = "data")
    @Temporal(TemporalType.DATE)
    private Date data;
    @Basic(optional = false)
    @NotNull
    @Column(name = "hora")
    @Temporal(TemporalType.TIME)
    private Date hora;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fkEncomenda")
    private List<ItemEncomenda> itemEncomendaList;
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "idEncomenda")
    private Integer idEncomenda;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "recebeu")
    private String recebeu;
    @Basic(optional = false)
    @NotNull
    @Column(name = "estado")
    private boolean estado;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "fkEncomenda")
    private List<Compra> compraList;
    @JoinColumn(name = "fkFuncionario", referencedColumnName = "idFuncionario")
    @ManyToOne(optional = false)
    private Funcionario fkFuncionario;
    @JoinColumn(name = "fkidFornecedor", referencedColumnName = "idFornecedor")
    @ManyToOne(optional = false)
    private Fornecedor fkidFornecedor;

    public Encomenda() {
    }

    public Encomenda(Integer idEncomenda) {
        this.idEncomenda = idEncomenda;
    }

    public Encomenda(Integer idEncomenda, Date data, Date hora, String recebeu, boolean estado) {
        this.idEncomenda = idEncomenda;
        this.data = data;
        this.hora = hora;
        this.recebeu = recebeu;
        this.estado = estado;
    }

    public Integer getIdEncomenda() {
        return idEncomenda;
    }

    public void setIdEncomenda(Integer idEncomenda) {
        this.idEncomenda = idEncomenda;
    }

    public String getRecebeu() {
        return recebeu;
    }

    public void setRecebeu(String recebeu) {
        this.recebeu = recebeu;
    }

    public boolean getEstado() {
        return estado;
    }

    public void setEstado(boolean estado) {
        this.estado = estado;
    }

    @XmlTransient
    public List<Compra> getCompraList() {
        return compraList;
    }

    public void setCompraList(List<Compra> compraList) {
        this.compraList = compraList;
    }

    public Funcionario getFkFuncionario() {
        return fkFuncionario;
    }

    public void setFkFuncionario(Funcionario fkFuncionario) {
        this.fkFuncionario = fkFuncionario;
    }

    public Fornecedor getFkidFornecedor() {
        return fkidFornecedor;
    }

    public void setFkidFornecedor(Fornecedor fkidFornecedor) {
        this.fkidFornecedor = fkidFornecedor;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idEncomenda != null ? idEncomenda.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Encomenda)) {
            return false;
        }
        Encomenda other = (Encomenda) object;
        if ((this.idEncomenda == null && other.idEncomenda != null) || (this.idEncomenda != null && !this.idEncomenda.equals(other.idEncomenda))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entidades.Encomenda[ idEncomenda=" + idEncomenda + " ]";
    }

    public Date getData() {
        return data;
    }

    public void setData(Date data) {
        this.data = data;
    }

    public Date getHora() {
        return hora;
    }

    public void setHora(Date hora) {
        this.hora = hora;
    }

    @XmlTransient
    public List<ItemEncomenda> getItemEncomendaList() {
        return itemEncomendaList;
    }

    public void setItemEncomendaList(List<ItemEncomenda> itemEncomendaList) {
        this.itemEncomendaList = itemEncomendaList;
    }
    
}
